package com.hnnu.shoppingtoghter.demo.service.impl;

import com.hnnu.shoppingtoghter.demo.entity.Contact;
import com.hnnu.shoppingtoghter.demo.mapper.SysContactMapper;
import com.hnnu.shoppingtoghter.demo.service.SysContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: 你的名字
 * @CreateTime： 2022/7/7 2:51
 */
@Service
public class SysContactServiceImpl implements SysContactService {

    @Autowired
    private SysContactMapper sysContactMapper;

    /**
     * @param contact
     * @Description: 查询列表
     * @Author: Liu_aihuan
     * @CreateTime: 2022/7/7 2:53
     * @param: contact
     * @return: java.util.List<com.hnnu.shoppingtoghter.demo.entity.Contact>
     */
    @Override
    public List<Contact> selectListByContact(Contact contact) {
        List<Contact> contactList = sysContactMapper.selectListByContact(contact);
        return contactList;
    }

    @Override
    public int updateContactIsdefault(Long userId, Long contactId) {
        sysContactMapper.updateContactIsdefaultPre(userId);

        return sysContactMapper.updateContactIsdefaultPost(contactId);
    }

    @Override
    public int insertContact(Contact contact) {
        return sysContactMapper.insertContact(contact);
    }

    @Override
    public Contact selectContactById(Long id) {
        return sysContactMapper.selectContactById(id);
    }

    @Override
    public int deleteByContactId(Long contactId) {
        int rows = sysContactMapper.deleteById(contactId);
        return rows;
    }

    @Override
    public int updateContact(Contact contact) {
        return sysContactMapper.updateContact(contact);
    }

//    @Override
//    public int updateContactIsdefaultPost(Long contactId) {
//        return sysContactMapper.updateContactIsdefaultPost(contactId);
//    }

}
